<?php

namespace app\common\model;

use think\Model;

class Package extends Model
{
    protected $table = 'oauth_order';
    
    
    /**
     * 通过订单id获取用户数据
     * @param $phone
     * @return array|null|\PDOStatement|string|\think\Model
     * @throws \think\Exception\DbException
     */
    public static function getLangClassInfo($oauth_id,$type)
    {
        $data = static::field('a.order_sn,a.oauth_id as uid,a.lang_id,b.id,b.name,c.id as class_id,c.lang_id,d.class_id,d.type,d.word')
                ->alias('a')
                ->join('lang b', 'a.lang_id = b.id')
                ->join('lang_class c', 'b.id = c.lang_id')
                ->join('lang_class_recite d', 'c.id = d.class_id')
                ->where(['a.oauth_id ' => $oauth_id, 'd.type' => $type])
                ->group('d.word')
                ->select()
                ->toArray();
        return $data;
    }
}